import { createRouter, createWebHistory } from 'vue-router'
import { routes } from './routes'
import type { RouteLocationNormalized } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: routes,
})

router.afterEach((to: RouteLocationNormalized) => {
  if (to.meta.title) {
    document.title = to.meta.title
  } else {
    document.title = '智能客服后台管理系统'
  }
})

export default router
